<template>
	<view>
		<view class="state">
			<view :class="state==0?'s-title':'title'" @click="tab(0)">全部</view>
			<view :class="state==1?'s-title':'title'" @click="tab(1)">开放中</view>
			<view :class="state==2?'s-title':'title'" @click="tab(2)">待开放</view>
			<!-- <view :class="state==3?'s-title':'title'" @click="tab(3)">已关闭</view> -->
		</view>
		<view class="lc-list" v-for="(item,index) in list" @click="jobDetail(item.id)">
			<view class="lc-box">
				<view :class="item.work_status==3?'lc-title grey-color':'lc-title'">{{item.title}}</view>
				<view class="lc-money" v-if="item.work_status==1">{{item.price_text}}</view>
				<view class="lc-money black-color" v-if="item.work_status==2">{{item.price_text}}</view>
				<view class="lc-money grey-color" v-if="item.work_status==3">{{item.price_text}}</view>
			</view>
			<view class="lc-t-box">
				<view :class="item.work_status==3?'lc-name grey-color':'lc-name'">{{item.shop_name}}</view>
				<view class="lc-state" v-if="item.status==0">审核中</view>
				<block v-else>
					<view class="lc-state" v-if="item.work_status==2">待开放</view>
					<view class="lc-state grey-color" v-if="item.work_status==3">已关闭</view>
				</block>
				<view class="lc-state" v-if="item.status==3">审核失败</view>
			</view>
			<view class="lc-detail">
				<view class="lc-laber">
					<view :class="item.work_status==3?'grey-color':''" v-for="(name,num) in item.label_arr">{{name}}
					</view>
				</view>
				<view :class="item.work_status==3?'lc-address grey-color':'lc-address'">{{item.city}}</view>
			</view>
			<view class="lc-relu" v-if="item.status==3">
				<view>驳回原因：{{item.note}}</view>
			</view>
			<view class="lc-del">
				<view @click.stop="del(item.id)">删除职位</view>
			</view>
		</view>
		<view class="lc-add" @click="release">新增职位</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				app: getApp().globalData,
				state: 0,
				list: [],
				page: 1
			}
		},
		onShow() {
			this.page = 1
			this.list = []
			this.getList()
		},
		methods: {
			del(id) {
				this.app.post('/api/wanlshop/user/wodrkshopdel', {
					id: id,
				}).then(res => {
					console.log(res)
					uni.showToast({
						title: '删除成功',
						icon: "none"
					})
					setTimeout(() => {
						this.page = 1
						this.list = []
						this.getList()
					}, 1500)
				})
			},
			getList() {
				this.app.post('/api/wanlshop/user/wodrkshop', {
					page: this.page,
					work_status: this.state
				}).then(res => {
					console.log(res)
					this.list = this.list.concat(res.list.data)
				})
			},
			tab(state) {
				this.page = 1
				this.list = []
				this.state = state
				this.getList()
			},
			jobDetail(id) {
				uni.navigateTo({
					url: '/pages/lc/jobDetail/jobDetail?id=' + id
				})
			},
			release() {
				uni.navigateTo({
					url: '/pages/lc/release/release'
				})
			}
		},
		onReachBottom() {
			this.page += 1;
			this.getList();
		},
	}
</script>

<style lang="scss">
	.state {
		width: 750rpx;
		display: flex;
		justify-content: space-around;
		background-color: #FFFFFF;

		.s-title {
			// width: 120rpx; 
			line-height: 80rpx;
			border-bottom: 3px solid #84BD00;
			color: #84BD00;
			text-align: center;
			display: inline-block;
			margin-left: 20rpx;
			margin-right: 20rpx;
			font-size: 30rpx;
		}

		.title {
			// width: 120rpx;
			line-height: 80rpx;
			border-bottom: 2px solid #fff;
			display: inline-block;
			text-align: center;
			margin-left: 20rpx;
			margin-right: 20rpx;
			font-size: 30rpx;
		}
	}

	.lc-list {
		width: 690rpx;
		margin-top: 30rpx;
		margin-left: 30rpx;
		background-color: #FFFFFF;
		padding: 30rpx 0;
		border-radius: 16rpx;

		.lc-box {
			width: 630rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-left: 30rpx;

			.lc-title {
				font-size: 33rpx;
				color: #3D3D3D;
			}

			.lc-money {
				font-size: 33rpx;
				color: #84BD00;
				font-weight: bold;
			}

			.grey-color {
				color: #D8D8D8;
			}

			.black-color {
				color: #333333;
			}
		}

		.lc-t-box {
			width: 630rpx;
			margin-left: 30rpx;
			display: flex;
			margin-top: 14rpx;
			justify-content: space-between;
			align-items: center;

			.lc-name {
				font-size: 30rpx;
				color: #999999;
			}

			.lc-state {
				font-size: 30rpx;
				color: #FB4E2F;
			}

			.grey-color {
				color: #D8D8D8;
			}
		}

		.lc-relu {
			width: 630rpx;
			margin-left: 30rpx;
			background-color: #f7f7f7;
			padding: 30rpx 0;
			margin-top: 30rpx;
			border-radius: 16rpx;
			font-size: 26rpx;

			view {
				width: 570rpx;
				margin-left: 30rpx;
			}
		}

		.lc-del {
			width: 630rpx;
			margin-left: 30rpx;
			display: flex;
			justify-content: flex-end;
			align-items: center;
			margin-top: 30rpx;

			view {
				width: 150rpx;
				height: 65rpx;
				background-color: #84BD00;
				color: #FFFFFF;
				display: flex;
				justify-content: center;
				align-items: center;
				color: #FFFFFF;
				font-size: 26rpx;
				border-radius: 50rpx;
			}
		}

		.lc-detail {
			width: 630rpx;
			margin-left: 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 30rpx;

			.lc-laber {
				display: flex;

				view {
					font-size: 24rpx;
					color: #999999;
					padding: 0 16rpx;
					line-height: 40rpx;
					background-color: #F6F6F6;
					margin-right: 10rpx;
				}

				.grey-color {
					color: #D8D8D8;
				}

			}

			.lc-address {
				font-size: 24rpx;
				color: #999999;
			}

			.grey-color {
				color: #D8D8D8;
			}
		}
	}

	.lc-add {
		width: 690rpx;
		height: 82rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 50rpx;
		position: fixed;
		bottom: 60rpx;
		left: 30rpx;
		background-color: #84BD00;
	}
</style>